<?php


namespace app\common\traits;

/**
 * 控制器渲染辅助器
 * @package app\common\traits
 */
trait Controller
{
    public function index(){
        if($this->request->isPost()){
            return $this->service->getTableList();
        }
        return $this->fetch();
    }

    public function create(){
        if($this->request->isPost()){
            return $this->service->create();
        }
        $html = $this->service->getHtml();
        //如果设置了html的参数就渲染公共的create页面
        $this->assign(['html'=>$html]);

        return $this->fetch();
    }

    public function update(){
        if($this->request->isPost()){
            return $this->service->update();
        }

        $this->assign(['info'=>$this->service->getInfo()]);
        return $this->fetch();
    }

    public function delete(){
        return $this->service->delete();
    }
}